{include file="common/_header"}
{include file="common/_header1"}

<body class="layui-anim layui-anim-up">
    <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">系统管理</a>
            <a>
              <cite>账号管理</cite></a>
          </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>

    <div class="x-body">

        <xblock>
<!--            <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
            <button class="layui-btn" onclick="x_admin_show('添加用户','/admin/boxeadmin?user_id=0',800,400)"><i class="layui-icon"></i>  添 加</button>
            <!--            <span class="x-right" style="line-height:40px">共有数据：88 条</span>-->
        </xblock>

        <div class="layui-row">
            <form class="layui-form layui-col-md12 x-so">

                <div class="layui-input-inline">
                    <select name="group_id">
                        <option value="">——用户组——</option>
                        {volist name="data.group" id="val"}
                        <option value="{$val.group_id}" {if $data.get['group_id'] == $val['group_id']}selected{/if}>{$val.group_name}</option>
                        {/volist}
                    </select>
                </div>

                <input type="text" name="user_name"  placeholder="请输入管理员账号" value="{$data.get['user_name']}" autocomplete="off" class="layui-input">
                <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </form>
        </div>



        <table id="tables" class="layui-table">

            <thead>
            <tr>
                <th>IM编号</th>
                <th>用户组</th>
                <th>管理员账号</th>
                <th>姓名</th>
                <th>最后登录时间</th>
                <th>最后登录IP</th>
                <th>账号状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="data.data" id="vo"}
            <tr class="table_tr">
                <td>{$vo.user_id}</td>
                <td>{$vo.group_name}</td>
                <td>{$vo.user_name}</td>
                <td>{$vo.real_name}</td>

                <td>{notempty name="$vo.last_time"}
                    {$vo.last_time|date="Y-m-d H:i"}
                    {/notempty}
                </td>
                <td>{$vo.last_ip}</td>
                <td>{if $vo.status == 1}<span class="status_span">正常</span>{else /} <span class="status_span_2">异常</span> {/if}</td>
                <td>
                    <ul class="nav navbar-nav" style=" height: 30px; line-height: 10px;">
                        <li class="dropdown" style="height: 100%;">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" style=" height: 100%; line-height: 5px;">
                                操作
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a title="编辑"  onclick="x_admin_show('编辑用户', 'boxeadmin?user_id={$vo.user_id}', '800', '400')" href="javascript:;">编辑</a></li>
                                <li class="divider"></li>
                                <li><a title="删除" onclick="del('{$vo.user_id}')" href="javascript:;">删除</a></li>
                            </ul>
                        </li>
                    </ul>
                </td>

            </tr>
            {/volist}
            </tbody>
        </table>
        <div class="page_all">
            {$page|raw}
        </div>
    </div>
    <script>

        /*删除*/
        function del(id) {
            layer.confirm('您确定要删除该用户吗?', {btn: ['确定', '取消'], title: "提示"}, function () {
                $.ajax({
                    url: 'deladmin?id=' + id,
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        console.log(data);
                        layer.msg(data.msg, {
                            icon: 6,
                            time: 500,
                        }, function () {
                            window.location.reload();
                        })
                    }
                })
            });
        }

        /*更新*/
        function edit() {
            var id = $("input:radio:checked").val();
            x_admin_show('编辑用户', 'edit?id=' + id, '900', '800');

        }

        // 搜索
        // Ajaxpage();
        // function Ajaxpage(curr) {
        //     var key = $('#keydown').val();
        //     var num = $('#num').val();
        //     $.getJSON('{:url("/admin/Repl/please")}', {
        //         page: curr || 1, key:key, key: num
        //     }, function (data) {
        //         console.log(data);
        //     })
        // }

        $(function () {
            // 表格选中行的同时选中单选框
            $("#tables tr:gt(0)").click(function () {
                $(this).find(":radio").prop("checked", true);
            });

        });

        //js放到table下，才能检测到tr数组
        var trs = document.getElementById("tables").getElementsByTagName("tr");
        $(function () {
            for (var i = 0; i < trs.length; i++) {
                trs[i].onmousedown = function () {
                    mousedownclick(this);
                }
            }
        });

        function mousedownclick(obj) {
            for (var j = 0; j < trs.length; j++) {
                if (trs[j] == obj) {
                    if (trs[0] != obj) {
                        trs[j].style.background = '#D0E9C6';
                        // 启用新增和编辑按钮
                        $("#edits").removeAttr("disabled");//启用按钮
                        $('#edits').removeClass('layui-disabled');
                    }
                } else {
                    trs[j].style.background = '';
                }
            }
        }
    </script>
</body>

{include file="common/_bottom"}